package com.example.demo0203.controller;

import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
@RequestMapping("/user")
public class UserController {

    private static final Object lock = new Object();

    @GetMapping
    public String sms(@RequestParam String sms) throws InterruptedException {
        String pwd = sms;
        System.out.println(Thread.currentThread().getId());
        Thread.sleep(10000);
        return pwd;
    }

    public static void main(String[] args) throws InterruptedException {
        UserController userController = new UserController();
        ExecutorService pool = Executors.newFixedThreadPool(10);
        pool.submit(() -> {
            try {
                System.out.println(userController.sms("aaa"));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

        pool.submit(() -> {
            try {
                System.out.println(userController.sms("ddd"));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

    }

}
